package pers.xhh.shopapi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.xhh.shopapi.annotation.UserLoginToken;
import pers.xhh.shopapi.common.Mi;
import pers.xhh.shopapi.entity.to.receiver.MiReceiverPutTo;
import pers.xhh.shopapi.service.MiReceiverService;

/**
 * @author wei-xhh
 * @date 2020-12-13
 */
@CrossOrigin
@RestController
@RequestMapping("/api/v1")
public class MiReceiverController {

    @Autowired
    MiReceiverService miReceiverService;

    @UserLoginToken
    @PutMapping("/receiver/{id}")
    public Mi updateReceiver(@PathVariable("id") Integer receiverId,
                             @RequestBody MiReceiverPutTo miReceiverPutTo){
        return miReceiverService.updateReceiver(receiverId, miReceiverPutTo);
    }

    @UserLoginToken
    @GetMapping("/receiver/{id}")
    public Mi updateReceiver(@PathVariable("id") Integer receiverId){
        return miReceiverService.getReceiverById(receiverId);
    }



}
